clear all

set linesize 120


local date	"`c(current_date)'"
local user  "`c(username)'"

capture log close
log using "log `date'.txt", text replace

use "food_protest_johannesburg.dta", clear
lab data "Food & Protest in Johannesburg by Rudolfsen & Smith"

*Census 2011 for Soweto and Alexandra combined 
gen fpc = 805/1451252

svyset, clear
svyset a05a, singleunit(certainty) vce(linearized) fpc(fpc)  || a05b 
svydescribe

*********************
*Dependent variables*
*********************

*Most likely action
rename e01 act

*Drop if response "Don't know/refused"
drop if act == .b

*How likely to forego wages to take action?
rename e02 act_resolve

*Remove "Do nothing"
replace act_resolve = . if act == 1

*Remove if missing
replace act_resolve = . if act == .b

*Aggregate outcome variable*
gen act_dum = . 
replace act_dum = 1 if act > 1
replace act_dum = 0 if act == 1


**********************
*Independent variable*
**********************

*Experimental condition
rename e00 exp_con

*Drop if no experiment
drop if exp_con == .a

*Split experimental conditions
tab exp_con, gen(exp)

*Split response
tab act, gen(act)

*Experimental condition with missing
gen fuel_price = 1 if exp_con == 2
replace fuel_price = 0 if exp_con == 1

gen food_price = 1 if exp_con == 3
replace food_price = 0 if exp_con == 1

gen elec_price = 1 if exp_con == 4
replace elec_price = 0 if exp_con == 1

*Enumerator
rename a01 enumerator
rename d01 gender
rename d02 age
rename d08 edu
rename c06 politics

*Went hungry because couldn't afford food
rename f05 hunger

gen fuel_price_increase = . 
replace fuel_price_increase = 1 if exp_con == 2
replace fuel_price_increase = 0 if fuel_price_increase == .

gen food_price_increase = . 
replace food_price_increase = 1 if exp_con == 3
replace food_price_increase = 0 if food_price_increase == .

gen elec_price_increase = . 
replace elec_price_increase = 1 if exp_con == 4
replace elec_price_increase = 0 if elec_price_increase == .



save "analysis.dta", replace

